package cn.sunlight.college.serviceEdu.controller;


import cn.sunlight.college.common.utils.R;
import cn.sunlight.college.serviceEdu.entity.subject.OneSubject;
import cn.sunlight.college.serviceEdu.service.EduSubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author sunlight
 * @since 2021-06-14
 */
@Api(description = "课程科目")
@RestController
@RequestMapping("/serviceEdu/subject")
@CrossOrigin
public class EduSubjectController {

    @Autowired
    private EduSubjectService subjectService;

    /**
     * 课程分类列表（树形）
     * @return
     */
    @ApiOperation(value = "课程分类列表（树形）")
    @GetMapping("getAllSubject")
    public R getAllSubject(){

        List<OneSubject> list=subjectService.getAllOneTwoSubject();
        return R.ok().data("list",list);
    }

    //添加课程分类
    //获取上传过来的文件，把文件内容读取出来
    @ApiOperation(value = "添加课程分类")
    @PostMapping("addSubject")
    public R addSubject(MultipartFile file){

        subjectService.saveSubject(file,subjectService);
        return R.ok();
    }

}

